package com.pubinfo.passbook.common.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.pubinfo.passbook.common.model.constant.ProvinceCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.EnumUtils;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 报账收款方信息表
 *
 * @TableName t_witeoff_pay_ment
 */
@ApiModel(value = "TWiteoffPayMent", description = "报账收款方信息表,接收前端报账单数据")
@TableName(value = "t_witeoff_pay_ment")
@Data
@NoArgsConstructor
public class TWiteoffPayMent implements Serializable {
  /**
   *
   */
  @TableId(type = IdType.ASSIGN_UUID, value = "id")
  @ApiModelProperty(hidden = true)
  private String id;
  
  /**
   * 银行账号
   */
  @ApiModelProperty(value = "银行账号")
  private String employeeBankAccount;
  
  /**
   * 收款方名称
   */
  @ApiModelProperty(value = "收款方名称")
  private String employeeName;
  
  /**
   * 银行名称
   */
  @ApiModelProperty(value = "银行名称")
  private String bank;
  
  /**
   * 所属银行代码
   */
  @ApiModelProperty(value = "所属银行代码")
  private String bankCode;
  
  /**
   * 收款方编码	对外收款方必须	供应商/客户编码
   */
  @ApiModelProperty(value = "收款方编码 对外收款方必须 供应商/客户编码")
  private String payeeCode;
  
  /**
   * 账户类型	非必须	1-对外对公，3-对外对私,2-对内
   */
  @ApiModelProperty(value = "账户类型 非必须 1-对外对公，3-对外对私,2-对内")
  private Byte accountType;
  
  /**
   * 外部收款方类型	非必须	银行账户类型 外部收款方类型,用于区分D-客户, K-供应商
   */
  @ApiModelProperty(value = "外部收款方类型 非必须 银行账户类型 外部收款方类型,用于区分D-客户, K-供应商")
  private String payeeType;
  
  /**
   * 开户行号
   */
  @ApiModelProperty(value = "开户行号")
  private String rowno;
  
  /**
   * 开户行地址
   */
  @ApiModelProperty(value = "开户行地址")
  private String bankAddress;
  
  /**
   * 所在省
   */
  @ApiModelProperty(value = "所在省")
  private String province;
  
  /**
   * 所在市
   */
  @ApiModelProperty(value = "所在市")
  private String city;
  
  /**
   * 币种
   */
  @ApiModelProperty(value = "币种")
  private String currency;
  
  /**
   * 付款金额
   */
  @ApiModelProperty(value = "付款金额")
  private Double sum;
  
  /**
   * 员工编码	对内收款方必须
   */
  @ApiModelProperty(value = " 员工编码 对内收款方必须")
  private String employeeCode;
  
  /**
   * 主次账号	对内收款方必须
   */
  @ApiModelProperty(value = " 主次账号 对内收款方必须")
  private String zcAccount;
  
  /**
   * 收款方用途
   */
  @ApiModelProperty(value = "收款方用途")
  private String desc;
  
  /**
   * 报账单id
   */
  @ApiModelProperty(hidden = true)
  private String otherSystemMainId;
  
  @TableField(exist = false)
  private static final long serialVersionUID = 1L;
  
  public TWiteoffPayMent(String employeeCode) {
    this.employeeCode = employeeCode;
  }
  
  public TWiteoffPayMent(String employeeCode, BigDecimal sum) {
    this.employeeCode = employeeCode;
    this.sum = sum.doubleValue();
  }
  
  public TWiteoffPayMent(TMdmSupplierBank supplierBank,BigDecimal sum) {
    this.bank = supplierBank.getBanka();
    this.bankCode = supplierBank.getBankl();
    this.payeeCode = supplierBank.getLifnr();
    if (supplierBank.getZpubPri().equals("对公")) {
      this.accountType = 1;
    } else {
      this.accountType = 3;
    }
    this.payeeType = "k";
    this.rowno = supplierBank.getBrnch();
    this.bankAddress = supplierBank.getBanka();
    this.province = supplierBank.getZprovz1();
    this.city = EnumUtils.getEnum(ProvinceCode.class, supplierBank.getOrt01()).getName();
    this.currency = supplierBank.getBanks();
    this.sum = sum.doubleValue();
  }
}